Skip to content

Conversation

gusin13
Copy link
Contributor

@gusin13 gusin13 commented Jul 4, 2025

No description provided.

@gusin13
Copy link
Contributor Author

gusin13 commented Jul 4, 2025

🚀 Starting Rollup BSN Demo
=============================
🔧 Building crypto operations tool...
  ✅ Crypto operations tool built successfully
Using admin address: bbn1g9h8yj2y53k60098en0xp4hkts8pwwv46vfc63

📋 Step 1: Deploying finality contract...
  → Storing contract WASM...
  → Command: /bin/babylond --home /babylondhome tx wasm store /contracts/op_finality_gadget.wasm --from test-spending-key --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn --output json -y
gas estimate: 4357329
  → Output: {"height":"0","txhash":"04E5B3E6029CEE16E5161BB45720C587527BE000B084FBFD5900B50731D19E24","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  🔍 Measuring gas for: Store Contract WASM
  → TX Hash: 04E5B3E6029CEE16E5161BB45720C587527BE000B084FBFD5900B50731D19E24
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "2924297" units (Block: "14")
"2924297"
  ✅ Contract WASM stored successfully!
  → Instantiating contract...
  → Command: /bin/babylond --home /babylondhome tx wasm instantiate 1 '{"admin":"bbn1g9h8yj2y53k60098en0xp4hkts8pwwv46vfc63","consumer_id":"consumer-id","is_enabled":true}' --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn --label 'finality' --admin bbn1g9h8yj2y53k60098en0xp4hkts8pwwv46vfc63 --from test-spending-key --output json -y
gas estimate: 226125
  → Output: {"height":"0","txhash":"877223C3D189D842ACC31D7678B19740254152EB8A6FFFE7112948B21BFC4656","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  🔍 Measuring gas for: Instantiate Contract
  → TX Hash: 877223C3D189D842ACC31D7678B19740254152EB8A6FFFE7112948B21BFC4656
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "170114" units (Block: "17")
"170114"
  ✅ Finality contract deployed at: bbn14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sw76fy2

🔗 Step 2: Registering consumer chain...
  → Command: /bin/babylond --home /babylondhome tx btcstkconsumer register-consumer consumer-id consumer-name consumer-description bbn14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sw76fy2 --from test-spending-key --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn --output json -y
gas estimate: 65883
  → Output: {"height":"0","txhash":"6275503B72373A6E637DDAF99171B666A9606CFC724E2DF202F25C2318563838","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  🔍 Measuring gas for: Register Consumer
  → TX Hash: 6275503B72373A6E637DDAF99171B666A9606CFC724E2DF202F25C2318563838
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "63243" units (Block: "20")
"63243"
  ✅ Consumer 'consumer-id' registered successfully

🔐 Step 3: Generating cryptographic keys...
  → Generating BTC key pairs for finality providers...
  ✅ Babylon FP BTC PK: f1a052bf57b563c38c0ebd1a67d32fe46a41fafad312cd11a3cb16f15204200b
  ✅ Babylon FP BTC SK: a75ff07a2c0cb6a035e779c38268decd76613a4d1e1a3910241acbfb252d6f94
  ✅ Consumer FP BTC PK: c7080280d5f90894dae8e9ae073d1dd9049569acb7fcb8006ade362ce9eceaff
  ✅ Consumer FP BTC SK: 41b04c023bc3ac992551a64649512ce774cfde43fdc8472b8d91a2c722701e98

👥 Step 4: Creating finality providers on-chain...
  → Using admin address for PoP: bbn1g9h8yj2y53k60098en0xp4hkts8pwwv46vfc63
  → Creating Babylon Finality Provider...
  → Command: /bin/babylond --home /babylondhome tx btcstaking create-finality-provider f1a052bf57b563c38c0ebd1a67d32fe46a41fafad312cd11a3cb16f15204200b 1240370cf135f66d255850c85dccb6bc579301b8628203ccb456e941258f16aa5292ac26fc394dfe4a7723e3d98239ec82bab531586609bc66fd87bebe68c2c5891c --from test-spending-key --moniker 'Babylon FP' --commission-rate 0.05 --commission-max-rate 0.10 --commission-max-change-rate 0.01 --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn --output json -y
gas estimate: 70611
  → Output: {"height":"0","txhash":"A89444FD139EA99B1C8A4C60F0ACBBA1F56E20AAD0C2090CD8D1DD5ACE62D631","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  🔍 Measuring gas for: Create Babylon Finality Provider
  → TX Hash: A89444FD139EA99B1C8A4C60F0ACBBA1F56E20AAD0C2090CD8D1DD5ACE62D631
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "66395" units (Block: "26")
"66395"
  ✅ Babylon FP created successfully
  → Creating Consumer Finality Provider...
  → Command: /bin/babylond --home /babylondhome tx btcstaking create-finality-provider c7080280d5f90894dae8e9ae073d1dd9049569acb7fcb8006ade362ce9eceaff 124086d21132d951973f7c3038fe9ccf3879541e77c9238177a2db0211f7f14f5feba9b36049db139a2efbc96b074a96c6193ce65c40306510d19e0bde77aabbda21 --from test-spending-key --moniker 'Consumer FP' --commission-rate 0.05 --commission-max-rate 0.10 --commission-max-change-rate 0.01 --consumer-id consumer-id --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn --output json -y
gas estimate: 94821
  → Output: {"height":"0","txhash":"386F748CB225191861578F7B35B89F9A95E61739B45791B7F8870FE1BFCDC8E9","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  🔍 Measuring gas for: Create Consumer Finality Provider
  → TX Hash: 386F748CB225191861578F7B35B89F9A95E61739B45791B7F8870FE1BFCDC8E9
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "82535" units (Block: "29")
"82535"
  ✅ Consumer FP created successfully
  → Verifying finality providers...
  ✅ Babylon finality providers: 1
  ✅ Consumer finality providers: 1

₿ Step 5: Creating BTC delegation...
  → Getting available BTC addresses...
  → Delegating 1000000 satoshis for 10000 blocks...
    From: bcrt1q6anphxawhvtjj7475gd7vun5xk4yzsldt5r22m
    To FPs: Babylon (f1a052bf57b563c38c0ebd1a67d32fe46a41fafad312cd11a3cb16f15204200b) + Consumer (c7080280d5f90894dae8e9ae073d1dd9049569acb7fcb8006ade362ce9eceaff)
  ✅ BTC delegation created: 7e396e4f656b69be1fdcf015250d0e5570a4295b3b5f5e422122c6ce5c1e4fb3

⏳ Step 6: Waiting for delegation activation...
  → Monitoring delegation status...
    Attempt 1/30: 0 active delegations, waiting...
    Attempt 2/30: 0 active delegations, waiting...
    Attempt 3/30: 0 active delegations, waiting...
    Attempt 4/30: 0 active delegations, waiting...
    Attempt 5/30: 0 active delegations, waiting...
    Attempt 6/30: 0 active delegations, waiting...
    Attempt 7/30: 0 active delegations, waiting...
    Attempt 8/30: 0 active delegations, waiting...
    Attempt 9/30: 0 active delegations, waiting...
    Attempt 10/30: 0 active delegations, waiting...
    Attempt 11/30: 0 active delegations, waiting...
    Attempt 12/30: 0 active delegations, waiting...
    Attempt 13/30: 0 active delegations, waiting...
  ✅ Delegation activated successfully!

🎲 Step 7a: Generating and committing public randomness...
  → Using crypto-ops to generate randomness (crypto-only)...
    Start height: 1, Number of commitments: 50000
  → Generating public randomness commitment data for blocks 1 to 50000...
  → Generating public randomness list...
  → Generated 50000 public randomness values starting at height 1
  ✅ Public randomness commitment data generated successfully!
  → Submitting commitment to finality contract...
    Contract: bbn14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sw76fy2
    FP PubKey: c7080280d5f90894dae8e9ae073d1dd9049569acb7fcb8006ade362ce9eceaff
    Commitment: "r5fBvHp1PEUsLvchTa9AgppM8JUpm7nfddsdH2WkYVM="
  → Command: /bin/babylond --home /babylondhome tx wasm execute bbn14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sw76fy2 '{
  "commit_public_randomness": {
    "fp_pubkey_hex": "c7080280d5f90894dae8e9ae073d1dd9049569acb7fcb8006ade362ce9eceaff",
    "start_height": 1,
    "num_pub_rand": 50000,
    "commitment": "r5fBvHp1PEUsLvchTa9AgppM8JUpm7nfddsdH2WkYVM=",
    "signature": "berd9P0xVYu+xXV7t4TyHv0h7JrF4Yv+OUccBKNVcOqCiyVioP5pRDG5buTKnmEeDTtRqEFoDqmQNrr61orVhw=="
  }
}' --from test-spending-key --chain-id chain-test --keyring-backend test --gas auto --gas-adjustment 1.5 --gas-prices 1ubbn -y --output json
gas estimate: 195018
  → Output: {"height":"0","txhash":"64F93948CBE77B342201D018B69505DB0CAC875651D5CB9227BB0818C69B77EA","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
  → Commit TX Hash: 64F93948CBE77B342201D018B69505DB0CAC875651D5CB9227BB0818C69B77EA
  🔍 Measuring gas for: Public Randomness Commitment
  → TX Hash: 64F93948CBE77B342201D018B69505DB0CAC875651D5CB9227BB0818C69B77EA
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "149374" units (Block: "59")
"149374"
  → Verifying commitment was stored...
  → Verification result: {"data":{"start_height":1,"num_pub_rand":50000,"height":59,"commitment":[175,151,193,188,122,117,60,69,44,46,247,33,77,175,64,130,154,76,240,149,41,155,185,223,117,219,29,31,101,164,97,83]}}
  ✅ Public randomness committed successfully for 50000 blocks!

✍️ Step 7b: Generating and submitting finality signatures...
  → Processing 5 blocks using crypto-only approach...
    Processing blocks 1 to 5
  → [1/5] Processing block 1...
    → Generating finality signature (crypto-only)...
  → Reading randomness data from stdin...
  → Generating finality signature...
  → Block: height=1, hash=80f431406e716fc12e5912153de4a3366b3293e814b1e29bac2157557f7011eb
  → Generating EOTS signature using randomness index 0 for height 1...
  ✅ Finality signature generated for block height 1 using randomness index 0
    → Submitting finality signature to contract...
gas estimate: 262477
    → Submission result: {"height":"0","txhash":"479F139A56A80164D127F418F70C2DBDD7CEE20949769164A3FCDF8A516EE204","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
    → Finality TX Hash: 479F139A56A80164D127F418F70C2DBDD7CEE20949769164A3FCDF8A516EE204
  🔍 Measuring gas for: Finality Signature Block 1
  → TX Hash: 479F139A56A80164D127F418F70C2DBDD7CEE20949769164A3FCDF8A516EE204
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "194349" units (Block: "63")
"194349"
    → Verifying finality signature was recorded...
    → Verification attempt 1/5...
    ✅ Verification succeeded on attempt 1
    ✅ Block 1: Finality signature submitted and verified successfully
  → [2/5] Processing block 2...
    → Generating finality signature (crypto-only)...
  → Reading randomness data from stdin...
  → Generating finality signature...
  → Block: height=2, hash=743594321d702e93dc377ddacb67e97e3e8dda2289c35565e28125e2cfbddd0f
  → Generating EOTS signature using randomness index 1 for height 2...
  ✅ Finality signature generated for block height 2 using randomness index 1
    → Submitting finality signature to contract...
gas estimate: 262792
    → Submission result: {"height":"0","txhash":"672BF0EE4BDB6570F2D4D7E69100F21F4DF4317FA3D32C51829917B7351C9A56","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
    → Finality TX Hash: 672BF0EE4BDB6570F2D4D7E69100F21F4DF4317FA3D32C51829917B7351C9A56
  🔍 Measuring gas for: Finality Signature Block 2
  → TX Hash: 672BF0EE4BDB6570F2D4D7E69100F21F4DF4317FA3D32C51829917B7351C9A56
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "194559" units (Block: "66")
"194559"
    → Verifying finality signature was recorded...
    → Verification attempt 1/5...
    ✅ Verification succeeded on attempt 1
    ✅ Block 2: Finality signature submitted and verified successfully
  → [3/5] Processing block 3...
    → Generating finality signature (crypto-only)...
  → Reading randomness data from stdin...
  → Generating finality signature...
  → Block: height=3, hash=776c52409aec726f632022e8ac5284ed90acd9e53c23f52852925e210c3ee468
  → Generating EOTS signature using randomness index 2 for height 3...
  ✅ Finality signature generated for block height 3 using randomness index 2
    → Submitting finality signature to contract...
gas estimate: 262837
    → Submission result: {"height":"0","txhash":"A07124B32CBB203ED79628910F16656E864425C4A099774DBE7F653F664163B6","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
    → Finality TX Hash: A07124B32CBB203ED79628910F16656E864425C4A099774DBE7F653F664163B6
  🔍 Measuring gas for: Finality Signature Block 3
  → TX Hash: A07124B32CBB203ED79628910F16656E864425C4A099774DBE7F653F664163B6
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "194589" units (Block: "70")
"194589"
    → Verifying finality signature was recorded...
    → Verification attempt 1/5...
    ✅ Verification succeeded on attempt 1
    ✅ Block 3: Finality signature submitted and verified successfully
  → [4/5] Processing block 4...
    → Generating finality signature (crypto-only)...
  → Reading randomness data from stdin...
  → Generating finality signature...
  → Block: height=4, hash=62aed38f315e61e0a41905f3f2e24f4b0d394eac31b969f34eeba45d8f7e6557
  → Generating EOTS signature using randomness index 3 for height 4...
  ✅ Finality signature generated for block height 4 using randomness index 3
    → Submitting finality signature to contract...
gas estimate: 262612
    → Submission result: {"height":"0","txhash":"6D1194199CB3109EC4037507A4A953F62996644C44ED912F3F52527C2601C083","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
    → Finality TX Hash: 6D1194199CB3109EC4037507A4A953F62996644C44ED912F3F52527C2601C083
  🔍 Measuring gas for: Finality Signature Block 4
  → TX Hash: 6D1194199CB3109EC4037507A4A953F62996644C44ED912F3F52527C2601C083
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "194439" units (Block: "74")
"194439"
    → Verifying finality signature was recorded...
    → Verification attempt 1/5...
    ✅ Verification succeeded on attempt 1
    ✅ Block 4: Finality signature submitted and verified successfully
  → [5/5] Processing block 5...
    → Generating finality signature (crypto-only)...
  → Reading randomness data from stdin...
  → Generating finality signature...
  → Block: height=5, hash=ac0b825b7f90c1f99052c170704ab8a5d10ca6b02bb86228f471610617737fc4
  → Generating EOTS signature using randomness index 4 for height 5...
  ✅ Finality signature generated for block height 5 using randomness index 4
    → Submitting finality signature to contract...
gas estimate: 262702
    → Submission result: {"height":"0","txhash":"3EE5DA36117931A430D7051F0C7B3EFA78DE258ECC663910B56031FEA9EE72CF","codespace":"","code":0,"data":"","raw_log":"","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
    → Finality TX Hash: 3EE5DA36117931A430D7051F0C7B3EFA78DE258ECC663910B56031FEA9EE72CF
  🔍 Measuring gas for: Finality Signature Block 5
  → TX Hash: 3EE5DA36117931A430D7051F0C7B3EFA78DE258ECC663910B56031FEA9EE72CF
  → Attempt 1/10: Waiting for transaction to be processed...
  🔥 GAS USED: "194499" units (Block: "78")
"194499"
    → Verifying finality signature was recorded...
    → Verification attempt 1/5...
    ✅ Verification succeeded on attempt 1
    ✅ Block 5: Finality signature submitted and verified successfully

🎉 All 5 finality signatures processed successfully!
  📊 Successfully processed blocks 1 to 5

🎉 BTC Staking Integration Demo Complete!
==========================================

✅ Finality contract deployed: bbn14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sw76fy2
✅ Consumer chain registered: consumer-id
✅ Finality providers created: 1 Babylon + 1 Consumer
✅ BTC delegation active: 7e396e4f656b69be1fdcf015250d0e5570a4295b3b5f5e422122c6ce5c1e4fb3 (1 active)
✅ Public randomness committed: blocks 1-50000 (50000 total)
✅ Finality signatures processed: 5/5 blocks (blocks 1-5)

@gusin13
Copy link
Contributor Author

gusin13 commented Jul 4, 2025

I added some debug statements to print gas usage per tx, as seen for committing pub rand for 50k blocks its around 149,374 units, this is around 2.5x as compared to Babylon FP (i.e when Babylon FP submits pub rand to genesis)

https://babylon.explorers.guru/transaction/05A032D3B01DD6CC799029D7E93ABE7807C4F8D8F193BDA8D1BEBC576E23E897?height=747989

for 50K blocks, on mainnet it takes 62,202 units

similar story for finality sigs, for rollup BSN it takes around 194,439 units as seen in above output, while on mainnet its around 108,345
https://babylon.explorers.guru/transaction/05B1EFC666C6DB26FE5A6CF2B35CFE5D1E9D621EA66C6191B8665AB8AE53FD00?height=752610

almost ~1.8x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant